/**
 * @param {number} numRows
 * @return {number[][]}
 */
var generate = function (numRows) {
  const res = [[1]]
  if (numRows === 1) return res
  const bianli = (time, arr) => {
    if (time === numRows) return
    time++
    if (arr.length === 1) {
      res.push([1, 1])
      bianli(time, [1, 1])
    } else {
      const newarr = [1]
      for (let i = 0; i < arr.length - 1; i++) {
        newarr.push(arr[i] + arr[i + 1])
      }
      newarr.push(1)
      res.push(newarr)
      bianli(time, newarr)
    }
  }
  bianli(1, [1])
  return res
}
console.log(generate(5))
